System Variables: Sinclair ZX Spectrum


Sinclair ZX Spectrum system Variables start at 23552 (23296 for 128K BASIC mode)

Address

Bytes

Name

Description

23296

20

SWAP

Paging Subroutine (Spectrum 128 BASIC)

23316

9

YOUNGR

Paging Subroutine (Spectrum 128 BASIC)

23325

18

ONERR

Paging Subroutine (Spectrum 128 BASIC)

23343

5

PIN

RS232 input preroutine (Spectrum 128 BASIC)

23348

22

POUT

RS232 token output preroutine. Can be patched to bypass the control code filter (Spectrum 128 BASIC)

23370

14

POUT2

RS232 character output preroutine (Spectrum 128 BASIC)

23384

2

TARGET

Subroutine address in ROM 1 (Spectrum 128 BASIC)

23386

2

RETADR

Return Address in ROM 0 (Spectrum 128 BASIC)

23388

1

BANKM

Copy of last byte output to Bank port (Spectrum 128 BASIC)

23389

1

RAMRST

RST 8 instruction (Spectrum 128 BASIC)

23390

1

RAMERR

Error Number, ROM 1 (Spectrum 128 BASIC)

23391

2

BAUD

RS232 bit period in T states/26 (Spectrum 128 BASIC)

23393

2

SERFL

Second-character-received-flag, and data (Spectrum 128 BASIC)

23395

1

COL

Current column from 1 to width (Spectrum 128 BASIC)

23396

1

WIDTH

Paper column width (Spectrum 128 BASIC)

23397

1

TVPARS

No. of inline parameters expected by RS232 (Spectrum 128 BASIC)

23398

1

FLAGS3

Various Flags (Spectrum 128 BASIC)

23399

10

N STR1

File name (Spectrum 128 BASIC)

23409

1

HD 00

Type of file code (Spectrum 128 BASIC)

23410

2

HD 0B

Length of Block (Spectrum 128 BASIC)

23412

2

HD 0D

Start of block (Spectrum 128 BASIC)

23414

2

HD 0F

Program length (Spectrum 128 BASIC)

23416

2

HD 11

Line number (Spectrum 128 BASIC)

23418

1

SC 00

Second set-File type code (Spectrum 128 BASIC)

23419

2

SC 08

Second set-Length of block (Spectrum 128 BASIC)

23421

2

SC 0D

Second set-Start of block (Spectrum 128 BASIC)

23423

2

SC 0F

Second set-Program length (Spectrum 128 BASIC)

23425

2

OLDSP

Old SP when TSTACK in use (Spectrum 128 BASIC)

23427

2

SFNEXT

Pointer to first empty directory entry (Spectrum 128 BASIC)

23429

3

SFSPACE

Number of bytes left (17 bit) (Spectrum 128 BASIC)

23432

1

ROW01

Keypad flags and row 1 image (Spectrum 128 BASIC)

23433

1

ROW23

Keypad rows 2 and 3 images (Spectrum 128 BASIC)

23434

1

ROW45

Keypad rows 4 and 5 images (Spectrum 128 BASIC)

23435

2

SYNRET

Return address for ONERR (Spectrum 128 BASIC)

23437

5

LASTV

Last value printed by calculator (Spectrum 128 BASIC)

23442

2

RNLINE

Current line being renumbered (Spectrum 128 BASIC)

23444

2

RNFIRST

Starting line number for RENUMBER (Spectrum 128 BASIC)

23446

2

RNSTEP

Incremental value for RENUMBER (Spectrum 128 BASIC)

23448

8

STRIP1

Stripe one bitmap (Spectrum 128 BASIC)

23456

8

STRIP2

Stripe two bitmap (Spectrum 128 BASIC)

23551

-X

TSTACK

Temporary stack grows down from here (Spectrum 128 BASIC)

23552

8

KSTATE

Working area of ROM procedure for reading the keyboard

23560

1

LAST K

Stores code of the last pressed key

23561

1

REPDEL

Time in Frames how long a key is pressed down before repeating (Original Value: 35)

23562

1

REPPER

Delay in Frames, between successive repeats of a pressed key

23563

2

DEF ADD

Address of arguments of User defined (FN) function if one is evauated, otherwise 0

23565

1

K DATA

2nd Byte of colour controls entered with keyboard code

23566

2

TV DATA

Stores bytes of colour or position (AT or TAB) going to Monitor

23568

38

STRMS

Relative channel Adresses connected to Streams:
23568: Stream 253, Channel "K"
23570: Stream 254, Channel "S"
23572: Stream 255, Channel "R"
23574: Stream 0, Channel "K"
23576: Stream 1, Channel "K"
23578: Stream 2, Channel "S"
23580: Stream 3, Channel "P"
23582 to 23604: Streams 4-15

23606

2

CHARS

Address (-256) of Character set (Font)

23608

1

RASP

Duration of the warning Beep

23609

1

PIP

Duration of keyboard click

23610

1

ERR NR

Error Code (-1) starts with 0 (255)

23611

1

FLAGS

Flags of I/O:
Bit 0: No Space in front of keyword
Bit 1: Using Printer
Bit 2: Cursor type (0=K, 1=L/C)
Bit 3: Input Type (0=K, 1=L/C)
Bit 5: Key was pressed
Bit 6: Data input (0=String, 1=Number)
Bit 7: Program executed

23612

1

TV FLAG

Screen Flags:
Bit 0: Set if entered lower screen part (Channel „K“)
Bit 3: Set if editing BASIC Line
Bit 4: Set on automatic LIST
Bit 5: Set if lower screen area should be cleared after key press

23613

2

ERR SP

Address of item on machine stack to be used as error return.

23615

2

LIST SP

Address of return address from automatic listing

23617

1

MODE

Cursor mode:
0: L/C
1: E
2: G
4: K

23618

2

NEWPPC

Line to be jumped to

23620

1

NSPPC

Statement number in line to be jumped to

23621

2

PPC

Line number of statement currently executed

23623

4

SUBPPC

Statement number within line currently executed

23624

1

BORDCR

Border colour *8 also contains the attribute normally used for the lower part of the screen

23625

2

E PPC

Number ol Line where cursor is

23627

2

VARS

Address of variables

23629

2

DEST

Address of variable assignment

23631

2

CHANS

Address of channel data

23633

2

CURCHL

Address of information currently being used for input and output

23635

2

PROG

Address of BASIC program

23637

2

NXTLIN

Address of next line in Program

23639

2

DATADD

Address of terminator of last DATA item

23641

2

E LINE

Address of command being typed in

23643

2

K CUR

Address of cursor

23645

2

CH ADD

Address of the next character to be interpreted: the character after the argument of PEEK or the NEWLINE at the end of POKE statement

23647

2

X PTR

Address of the Character after the „?“ marker

23649

2

WORKSP

Address of temporary work space

23651

2

STKBOT

Address of bottom of calculator stack

23653

2

STKEND

Address of start of spare space

23655

1

BREG

Calculator's b register

23656

2

MEM

Address of area used for calculator's memory (usually MEMBOT, bur not always)

23658

1

FLAGS2

Further Flags:
Bit 0: Set if screen was just cleared
Bit 1: Cleared if printer buffer is empty
Bit 2: Set if operation inside parenthysis
Bit 3: Set if CAPS LOCK is on
Bit 4: Set if „K“ is the current channel

23659

1

DF SZ

The number of lines (including one blank line) in the lower part of the screen

23660

2

S TOP

The number of the top program line in automatic listing

23662

2

OLDPPC

Line number to which CONTINUE jumps

23664

1

OSPPC

Number of Statement within the line, to which CONTINUE jumps

23665

1

FLAGX

More Flags:
Bit 1: Set if called non existing varable
Bit 5: Set if in INPUT mode, else in EDIT mode
Bit 7: Set if INPUT LINE is executed

23666

2

STRLEN

Length of string type destination in assignment

23668

2

T ADDR

Address of next item in syntax analysis table

23670

2

SEED

Seed for RND. This variable is set by RANDOMIZE

23672

3

FRAMES

3 Byte (least significant first), frame counter increased every 1/50th of second

23675

2

UDG

Address of 1st user defined Graphics

23677

1

COORDS

X-coordinate of last point ploted

23678

1

COORDS

Y-coordinate of last point ploted

23679

1

P POSN

33-column number of printer position

23680

1

PR CC

Less significant byte of address of next positiob for LPRINT to print at (in printer buffer)

23681

1

NONE

Not used

23682

2

ECHO E

33-column number and 24-line number (in lower part) of end of input buffer

23684

2

DF CC

Address in display file of PRINT position

23686

2

DFCCL

Like DF CC for lower part of screen

23688

2

S POSN

33-column number for PRINT position

23689

1

POSN

24-line number for PRINT-position

23690

2

SPOSNL

Like S POSN for lower part of screen

23692

1

SCR CT

Countsscrolls: it is always 1 more than the number of scrolls that will be done before stopping with „scroll?“.

23693

1

ATTR P

Permanent colours, etc (as set up by colour statements)

23694

1

MASK P

Mask used for transparent colours. Any set bit is taken not from ATTR P but from screen

23695

1

ATTR T

Temporary current colours

23696

1

MASK T

Temporary current colour mask

23697

1

P FLAG

Colour flags:
Bit 0: OVER temporary
Bit 1: OVER permanent
Bit 2: INVERSE temporary
Bit 3: INVERSE permanent
Bit 4: INK 9 temporary
Bit 5: INK 9 permanent
Bit 6: PAPER 9 temporary
Bit 7: PAPER 9 permanent

23698

30

MEMBOT

Calculator memory

23728

2

NMIADD

Holds the address of the users NMI service routine. Will cause reset if zero and NMI activated by a peripheral. Logic reversed on Spectrum +3. Also used by Interface 1 to vary print width on RS232 text channel

23730

2

RAMTOP

Address of last byte reachable for BASIC

23732

2

P-RAMT

Address of last byte of physical memory





23739

2

S-CHAN

Address for output of S-Channel


(c)2012 By LCD